/*
What is the effect of the following statements?
fflush(fp); -> flushes user space
fsync(fileno(fp)); -> flushes kernel space onto the disk
fdatasync -> flush and finish all operations on given file
*/

/*
Explain why the output of the following code differs depending on whether
standard output is redirected to a terminal or to a disk file.
printf("If I had more time, \n");
write(STDOUT_FILENO, "I would have written you a shorter letter.\n", 43);
*/

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int
main(void)
{
  printf("If I had more time, \n");
  fflush(stdout); // flush userspace is needed
  write(STDOUT_FILENO, "I would have written you a shorter letter.\n", 43);
  return EXIT_SUCCESS;
}
